<div style="">
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="logLoginTable" lay-filter="logLoginTable"></table>
        </div>
    </div>
</div>
<script type="text/html" id="logLoginStatusTpl">
    {{#  if(d.status =='1'){ }}
    <span class="layui-badge layui-bg-green">登录成功</span>
    {{#  } else { }}
    <span class="layui-badge layui-bg-danger">登录失败</span>
    {{#  } }}
</script>

<script type="text/html" id="logLoginAddressTpl">
    {{# let dCountry = '' }}
    {{# if(d.country !==''){ dCountry= d.country } }}
    {{# let dProvince = '' }}
    {{# if(d.province !==''){ dProvince= " - "+d.province } }}
    {{# let dCity = '' }}
    {{# if(d.city !==''){ dCity= " - "+d.city } }}
    {{dCountry}}{{dProvince}}{{dCity}}
</script>

<script>
  layui.use(['table', 'form', 'util'], function () {
    var $ = layui.jquery;
    var form = layui.form;
    var table = layui.table;
    var util = layui.util;
    form.render();
    var tableInit = table.render({
      elem: '#logLoginTable',
      toolbar: '#logLoginTableToolbar',
      defaultToolbar: [{
        layEvent: 'refresh',
        icon: 'layui-icon-refresh',
        title: '刷新'
      }, 'filter', 'exports'],
      method: 'get',
      url: "/app/admin/loglogin/select?field=id&order=desc",
      parseData: function (res) {
        return {
          "code": 0,
          "msg": res.msg,
          "count": res.count,
          "data": res.data
        };
      },
      cellMinWidth: 100,
      cols: [[
        {field: 'admin_name', title: '登录名', align: 'center'},
        {field: 'ip_address', title: 'ip地址', align: 'center'},
        {field: 'address', title: '地区', templet: '#logLoginAddressTpl'},
        {field: 'isp', title: '网络', align: 'center'},
        {field: 'status', title: '登录状态',align: 'center', templet: '#logLoginStatusTpl'},
        {field: 'create_time', title: '登录时间', align: 'center'}
      ]],
      page: true,
      limit: 10
    });

    // 表头工具栏工具事件
    table.on("toolbar(" + tableInit.config.id + ")", function (obj) {
      if (obj.event === "refresh") {
        refreshTable(tableInit.config.id, 1);
      }
    })

  });
</script>
